package com.demo.framework.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.TextView;

import com.demo.app.R;
import com.demo.framework.utils.StringUtil;

/**
 * 
* @ClassName: TaskProgressDialog 
* @Description: TODO(自定义 Dialog 样式) 
* @author Administrator 
* @date 2013-3-30 下午10:39:46 
* @version 1.0
 */
public class TaskProgressDialog extends Dialog {
    private String message;

    private TextView message_textview = null;

    public TaskProgressDialog(Context context, String message) {
        super(context, R.style.teamkn_progress_dialog);
        this.message = message;
    }

    public TaskProgressDialog(Context context, int resid) {
        super(context, R.style.teamkn_progress_dialog);
        this.message = context.getString(resid);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        setContentView(R.layout.task_progress_dialog);

        if (StringUtil.isNotBlank(this.message)) {
            message_textview = (TextView) findViewById(R.id.task_progress_dialog_message);
            message_textview.setText(this.message);
        }
    }

    public void setMessage(String message) {
        if (StringUtil.isNotBlank(this.message)) {
            message_textview.setText(message);
        }
    }

    /**
     * 
    *
    * @Title: show 
    * @Description: TODO(显示 progress Dialog) 
    * @param @param context
    * @param @param message
    * @param @return    设定文件 
    * @return TaskProgressDialog    返回类型 
    * @throws
     */
    public static TaskProgressDialog show(Context context, String message) {
        TaskProgressDialog dialog = new TaskProgressDialog(context, message);
//        dialog.show();
        return dialog;
    }

    /**
    *
    * @Title: show 
    * @Description: TODO(显示 progress Dialog) 
    * @param @param context
    * @param @param resid
    * @param @return    设定文件 
    * @return TaskProgressDialog    返回类型 
    * @throws
     */
    public static TaskProgressDialog show(Context context, int resid) {
        TaskProgressDialog dialog = new TaskProgressDialog(context, context.getString(resid));
//        dialog.show();
        return dialog;
    }

}
